#include <Windows.h>
#include "App.h"
#include "Renderer.h"
#include "Other.h"

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	CefMainArgs main_args(hInstance);
	CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
	command_line->InitFromString(::GetCommandLineW());

	CefRefPtr<BaseApp> app;
	if (!command_line->HasSwitch("type"))
	{
		app = new App();
	}
	else if (command_line->GetSwitchValue("type").ToString() == "renderer")
	{
		app = new Renderer();
	}
	else 
	{
		app = new Other();
	}

	CefSettings settings;
	int exitcode = CefExecuteProcess(main_args, app, nullptr);
	if (exitcode >= 0)
	{
		return exitcode;
	}

	CefInitialize(main_args, settings, app.get(), nullptr);
	CefRunMessageLoop();
	CefShutdown();
	
	return 0;
}